<?php
function pagination($page,$sum){
	global $dt_smarty;
    $url=$_SERVER['REQUEST_URI'];
   
    $url=str_replace("?page=$page",'',$url);
    
    $url=str_replace("&page=$page",'',$url);
   
	if(strpos($url,'?')===false){
		$url=$page-1;   
	} 
	$begin=max($page-2,1);
	$end=min($page+2,$sum); 
    $dt_smarty->assign('sum',$sum);
	$dt_smarty->assign('url',$url);
	$dt_smarty->assign('page',$page);
	$dt_smarty->assign('begin',$begin);
	$dt_smarty->assign('end',$end);
	return $dt_smarty->fetch('elements/pagination.tpl');
}